
<template>
  <div class="loads">
    <el-upload
      ref="replaceUploader"
      action="/api/threesuns/medias/upload"
      :limit="1"
      multiple
      :show-file-list="true"
      :on-success="handleReplaceAvatarSuccess"
      :on-exceed="handleExceed"
      :beforeUpload="beforeAvatarUpload"
    >
      <el-button size="small" icon="el-icon-upload2" type="primary">点击上传</el-button>
    </el-upload>
  </div>
</template>
<script>
export default {
  name: "uploadMusic",
  data() {
    return {
    };
  },
  methods: {
    beforeAvatarUpload(file) {
      var testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
      const extension = testmsg === "mp3";
      if (!extension) {
        this.$message({
          message: "上传文件只能是mp3格式！",
          type: "error"
        });
      }
      return extension;
    },
    handleReplaceAvatarSuccess(file) {
        this.$emit('Success',file)
    }
  }
};0
</script>
<style  scoped>
 /deep/ .el-upload__input {
  display: none;
}
/deep/ .el-upload {
  display: block;
}
.el-button {
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid #fff;
}
.el-button:active {
  border: 1px solid #ccc;
}
</style>